#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int my_strlen(char* str)
{
	/*int count = 0;
	while (*str != '\0')
	{
		str++;
		count++;
	}
	return count;*/
	
	
	/*if (*str == '\0')
	{
		return 0;
	}
	else
	{
		return my_strlen(str + 1) + 1;
	}*/

	char* p = str;
	while (*p != '\0')
	{
		p++;
	}
	return p - str;

}
char* my_strcpy(char* des, char* sta)
{
	char* ret = des;
	while(*des++=*sta++)
	{
		;
	}
	return ret;
}
char* my_strcat(char* des, char* sta)
{
	char* ret = des;
	while (*des != 0)
	{
		des++;
	}
	while (*des++ = *sta++)
	{
		;
	}
	return ret;
}
int my_strcmp(char* str1, char* str2)
{
	while (*str1++ == *str2++)
	{
		if (str1 == '\0')
		{
			return 0;
		}
		
	}
	if (*str1 > *str2)
	{
		return 1;
	}
	else
	{
		return -1;
	}
}
char* my_strstr(char* str1, char* str2)
{
	char* s1 = NULL;
	char* s2 = NULL;
	char* key = str1;
	while (*key)
	{
		s1 = key;
		s2 = str2;
		while (*s1 && *s2 && *s1 == *s2)
		{
			s1++;
			s2++;
		}
		if (*s2 == '\0')
		{
			return key;
		}
		key++;

	}
	return NULL;
}
int main1()
{
	char arr1[] = "abcdefg";
	int ret = my_strlen(arr1);
	printf("%d\n", strlen("abcdefg"));
	printf("%d", ret);
}
int main2()
{
	char arr1[20] = "";
	char arr2[] = "abc";
	/*strcpy(arr1, arr2);
	printf("%s", arr1);*/
	printf("%s",my_strcpy(arr1, arr2));
	

}
int main3()
{
	char arr1[] = "qqq";
	char arr2[] = "wwwwwwww";
	/*strcat(arr1, arr2);*/
	/*my_strcat(arr1, arr2);
	printf("%s", arr1);
	char* p = "abcdefg";*/
	/*int ret=strcmp(arr1, arr2);*/
	int ret=my_strcmp(arr1, arr2);
	printf("%d", ret);
	
	
}
int main11()
{
	char arr1[10] = "abc";
	char arr2[] = "nnn";
	/*strncpy(arr1, arr2, 5);*/
	/*strncat(arr1, arr2, 5);*/
	printf("%s", arr1);
}
int main()
{
	char arr1[] = "abcdefg";
	char arr2[] = "def";
	/*char* p = strstr(arr1, arr2);*/
	char* p = my_strstr(arr1, arr2);
	printf("%s", p);
}